package com.hmall.user.controller;

import com.hmall.user.pojo.Address;
import com.hmall.user.pojo.User;
import com.hmall.user.service.PayUserService;
import com.hmall.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("")
@RestController
public class UserController {

    @Autowired
    private  UserService userService;

    @Autowired
    private PayUserService payUserService;

    @GetMapping("/address/uid")
    public List<Address> getUserAdderss(){
       return userService.getUserAdderss();
    }


    @GetMapping("/address/{addressId}")
    public Address getAddressById(@PathVariable("addressId") Long addressId){

        return userService.getAdderssById(addressId);
    }

    @GetMapping("user/get")
    public User getUserById(@RequestParam Long userId){

        return payUserService.selectById(userId);
    }

    @GetMapping("/user/pay")
    public void update(@RequestParam Long status,@RequestParam Long userId ){
        payUserService.updateById1(status,userId);
    }
}
